
<!DOCTYPE HTML>
<html lang="en" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>MainPage  · Cup Documentation</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Guannan Ma">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-insert-logo/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    

    <style>
    @media only screen and (max-width: 640px) {
        .book-header .hidden-mobile {
            display: none;
        }
    }
    </style>
    <script>
        window["gitbook-plugin-github-buttons"] = {"repo":"baidu/CUP","types":["star","watch","fork"],"size":"large"};
    </script>

    
        <link rel="shortcut icon" href='images/cup.logo.jpg' type="image/x-icon">
    
    
        <link rel="bookmark" href='images/cup.logo.jpg' type="image/x-icon">
    
    
        <link rel="apple-touch-icon" href='images/cup.logo.jpg'>
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="https://github.com/baidu/CUP" target="_blank" class="custom-link">Github Website</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter active" data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    MainPage 
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" >
            
                <span>
            
                    
                    RoadMap
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="ChangeLog.html">
            
                <a href="ChangeLog.html">
            
                    
                    Release Note
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <a target="_blank" href="http://cupdoc.iobusy.com">
            
                    
                    Documentation
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >MainPage </a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="introduction"><a name="introduction" class="plugin-anchor" href="#introduction"><i class="fa fa-link" aria-hidden="true"></i></a>Introduction</h1>
<h2 id="quick-start"><a name="quick-start" class="plugin-anchor" href="#quick-start"><i class="fa fa-link" aria-hidden="true"></i></a>Quick Start</h2>
<h3 id="1-download"><a name="1-download" class="plugin-anchor" href="#1-download"><i class="fa fa-link" aria-hidden="true"></i></a>1. Download</h3>
<ul>
<li>git clone CUP or download the released tar balls</li>
</ul>
<h3 id="2-installation"><a name="2-installation" class="plugin-anchor" href="#2-installation"><i class="fa fa-link" aria-hidden="true"></i></a>2. Installation</h3>
<ul>
<li>run</li>
</ul>
<pre><code class="lang-bash">python setup.py install
</code></pre>
<h3 id="3-doc--wiki"><a name="3-doc--wiki" class="plugin-anchor" href="#3-doc--wiki"><i class="fa fa-link" aria-hidden="true"></i></a>3. Doc &amp; Wiki</h3>
<p>Visit Wiki to see more details: <a href="https://github.com/Baidu/CUP/wiki" target="_blank">https://github.com/Baidu/CUP/wiki</a>
Visit Doc site to see py-docs: <a href="http://cupdoc.iobusy.com/" target="_blank">http://cupdoc.iobusy.com/</a></p>
<pre><code class="lang-python"><span class="hljs-comment"># Examples:</span>
<span class="hljs-comment"># 1. Get system info</span>
<span class="hljs-keyword">import</span> cup
<span class="hljs-comment"># count cpu usage in interval, by default 60 seconds</span>
<span class="hljs-keyword">from</span> cup.res <span class="hljs-keyword">import</span> linux
cpuinfo = linux.get_cpu_usage(intvl_in_sec=<span class="hljs-number">60</span>)
<span class="hljs-keyword">print</span> cpuinfo.usr

<span class="hljs-comment"># total, available, percent, used, free, active, inactive, buffers, cached</span>
<span class="hljs-keyword">from</span> cup.res <span class="hljs-keyword">import</span> linux
meminfo = linux.get_meminfo()
<span class="hljs-keyword">print</span> meminfo.total
<span class="hljs-keyword">print</span> meminfo.available
</code></pre>
<h2 id="tests"><a name="tests" class="plugin-anchor" href="#tests"><i class="fa fa-link" aria-hidden="true"></i></a>Tests</h2>
<pre><code>- Install python-nose before running the tests
- run `cd ./cup_tests; nosetests -s`
</code></pre><h2 id="contribute-to-cup"><a name="contribute-to-cup" class="plugin-anchor" href="#contribute-to-cup"><i class="fa fa-link" aria-hidden="true"></i></a>Contribute To CUP</h2>
<pre><code>- Commit code to GITHUB, https://github.com/baidu/CUP
- Need to check pep8 and pylint rules before you start a pull request
</code></pre><h2 id="discussion"><a name="discussion" class="plugin-anchor" href="#discussion"><i class="fa fa-link" aria-hidden="true"></i></a>Discussion</h2>
<pre><code>- Github Issues
</code></pre><h2 id="reference"><a name="reference" class="plugin-anchor" href="#reference"><i class="fa fa-link" aria-hidden="true"></i></a>Reference</h2>
<pre><code>* Pexpect http://pexpect.sourceforge.net/ (under MIT license)
* Httplib2 http://code.google.com/p/httplib2/ (under MIT license)
* requests https://github.com/kennethreitz/requests (under Apache V2 license)
* pymysql https://github.com/PyMySQL/PyMySQL (under MIT license)
</code></pre><h2 id="wiki"><a name="wiki" class="plugin-anchor" href="#wiki"><i class="fa fa-link" aria-hidden="true"></i></a>WIKI</h2>
<pre><code>https://github.com/Baidu/CUP/wiki
</code></pre><h2 id="code-directory-tree"><a name="code-directory-tree" class="plugin-anchor" href="#code-directory-tree"><i class="fa fa-link" aria-hidden="true"></i></a>code directory tree:</h2>
<pre><code class="lang-text">    cup
    |-- cache.py                module              Memory cache related module
    |-- decorators.py           module              Decorators of python
    |-- err.py                  module              Exception classes for CUP
    |-- __init__.py             module              Default __init__.py
    |-- log.py                  module              CUP logging
    |-- mail.py                 module              CUP Email module (send emails)
    |-- net                     package             Network operations, such as net handler parameter tuning
    |-- oper.py                 module              Mixin operations
    |-- platforms.py            module              Cross-platform operations
    |-- res                     package             Resource usage queries (in /proc)&#x3001;Process query&#x3001;etc
    |-- shell                   package             Shell Operations&#x3001;cross-hosts execution
    |-- services                package             Heartbeat&#x3001;Threadpool based executors&#x3001;file service&#x3001;etc
    |-- thirdp                  package             Third-party modules&#xFF1A; pexpect&#x3001;httplib2
    |-- timeplus.py             module              Time related module
    |-- unittest.py             module              Unittest&#x3001;assert&#x3001;noseClass
    |-- util                    package             ThreadPool&#x3001;Interruptable-Thread&#x3001;Rich configuration&#x3001;etc
    |-- version.py              module              CUP Version
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"MainPage ","level":"1.1","depth":1,"next":{"title":"RoadMap","level":"1.2","depth":1,"ref":"","articles":[{"title":"Release Note","level":"1.2.1","depth":2,"path":"ChangeLog.md","ref":"ChangeLog.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["-sharing","splitter","anchors","sharing-plus","favicon","insert-logo","chinese-video","github-buttons"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"splitter":{},"search":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"anchor-navigation-ex":{"showLevel":false,"mode":"float","pageTop":{"showLevelIcon":true,"level1Icon":"fa fa-hand-o-right","level2Icon":"fa fa-hand-o-right","level3Icon":"fa fa-hand-o-right"}},"favicon":{"shortcut":"./images/cup.logo.jpg","bookmark":"./images/cup.logo.jpg","appleTouch":"./images/cup.logo.jpg"},"github-buttons":{"repo":"baidu/CUP","types":["star","watch","fork"],"size":"large"},"chinese-video":{},"sharing":{"qq":false,"all":["google","facebook","weibo","twitter","qq","qzone","linkedin","pocket"],"douban":false,"facebook":false,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":false,"vk":false,"pocket":false,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{},"insert-logo":{"style":"background: none;","url":"http://cup.iobusy.com/cup.logo.png"}},"theme":"default","author":"Guannan Ma","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Cup Documentation","language":"en","links":{"sidebar":{"Github Website":"https://github.com/baidu/CUP"}},"gitbook":"*","description":"Cup Documentation which you may refer to"},"file":{"path":"README.md","mtime":"2019-05-10T10:19:49.251Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-07-14T09:31:09.653Z"},"basePath":".","book":{"language":"en"}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-insert-logo/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-github-buttons/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

